from skel import *

s1 = readskel("01Asf.ske")
s2 = readskel("armadillo.ske")
match = matchskel (s1,s2)
print match
imatch = 0

from OpenGL.GL import *
from OpenGL.GLUT import *

def displayskeleton(s,highlight):
    vmin,vmax = s.box()
    cx,cy,cz = vector.scale(vector.add(vmin,vmax),0.5)
    sz = 1.8/max(vector.sub(vmax,vmin))
    glPointSize(5)
    glScalef(sz,sz,sz)
    glTranslatef(-cx,-cy,-cz)
    glColor3f(1,1,1)
    s.draw()
    glColor3f(1,0,0)
    s.drawvertices (highlight)
    
def display():
    glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    glViewport (0,0,400,400)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    displayskeleton(s1,[match[imatch][0]])
    glViewport (400,0,400,400)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    displayskeleton(s2,[match[imatch][1]])
    glutSwapBuffers()

def keyboard(key,x,y):
    global imatch
    imatch = (imatch+1)%len(match)
    glutPostRedisplay()

glutInit([]) 
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL)
glutInitWindowSize(800, 400)
glutCreateWindow("Test")
glutDisplayFunc(display)
glutKeyboardFunc(keyboard)
glutMainLoop()

